package com.hnue.k60b.adapter;

import com.hnue.k60b.newapplication.R;
import com.hnue.k60b.utils.Variables;

import android.R.color;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

@SuppressLint("ResourceAsColor")
public class paperadapter extends ArrayAdapter<String> {

	// moi hang sẽ có 2 cột, icon và tên báo

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// khi tao ra view mới, cho phép add thêm 1 hàng mới
		// systemservice sẽ trả về 1 object
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		// khởi tạo 1 dòng
		View rowview = inflater.inflate(R.layout.paper, parent, false);
		ImageView iv = (ImageView) rowview.findViewById(R.id.ivIcon_vnexpress);
		TextView tv = (TextView) rowview.findViewById(R.id.tvVnexpress);
		iv.setImageResource(Variables.ICONS[position]);
		tv.setText(paper[position]);
		return rowview;
	}

	private Context context;
	private String[] paper;

	public paperadapter(Context context, int textViewResourceId, String[] paper) {
		super(context, textViewResourceId, paper);
		this.context = context;
		this.paper = paper;
	}

}
